<template>
  <div class="container">
    <div class="top-box">
      <div class="left-box">
        <div class="color-box"></div>
        <p>申请调车</p>
      </div>
      <div class="right-box">
        <el-button type="info" icon="el-icon-back" class="btn_fanhui" @click="Return">返回</el-button>
      </div>
    </div>
    <div class="content-box">
      <div class="table-box">
        <ul>
          <li>
            <div class="item-box">申请数量</div>
            <div class="item1-box">
              <input type="text" v-model="item.Num" placeholder="请输入数量" />
            </div>
            <div class="item-box">驾驶员</div>
            <div class="item2-box">
              <el-form>
                <el-radio-group v-model="item.DriverNeed">
                  <el-radio label="1">需要</el-radio>
                  <el-radio label="2">不需要</el-radio>
                </el-radio-group>
              </el-form>
            </div>
          </li>
          <li>
            <div class="item-box">用车时间</div>
            <div class="item1-box">
              <div class="block">
                <el-date-picker v-model="item.UseTime" type="date" placeholder="选择日期"></el-date-picker>
              </div>
            </div>
            <div class="item-box">归还时间</div>
            <div class="item2-box">
              <div class="block">
                <el-date-picker v-model="item.ReturnTime" type="date" placeholder="选择日期"></el-date-picker>
              </div>
            </div>
          </li>
          <li>
            <div class="item-box">去往地点</div>
            <div class="item1-box">
              <input type="text" v-model="item.GoAddreess" placeholder="请输入地点" />
            </div>
            <div class="item-box">发车地点</div>
            <div class="item2-box">
              <input type="text" v-model="item.FromAddress" placeholder="请输入地点" />
            </div>
          </li>
          <li>
            <div class="item-box">借车公司</div>
            <div class="item6-box">
              <el-select v-model="item.Partners" placeholder="请选择">
                <el-option
                  v-for="item in company"
                  :key="item.Id"
                  :label="item.Name"
                  :value="item.Id"
                ></el-option>
              </el-select>
            </div>
          </li>
          <li class="large-box">
            <div class="item5-box">申请原因</div>
            <div class="item6-box">
              <textarea v-model="item.Reasons" placeholder="请输入原因"></textarea>
            </div>
          </li>
        </ul>
      </div>
      <div class="btn-box">
        <el-button type="primary" @click=" addlist()">确定</el-button>
        <el-button type="info" @click="Return">返回</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  data () {
    return {
      item: {
        Partners: "",
        Creater: 0,
        Num: "",
        DriverNeed: "1",
        UseTime: "",
        ReturnTime: "",
        GoAddreess: "",
        FromAddress: "",
        Reasons: "",
      },
      company: [{ Name: "", Id: 0 }],
      Mark: 0,
    }
  },
  created () {
    this.item.Creater = JSON.parse(localStorage.getItem("message")).Id;
    this.getCompany();
  },
  methods: {
    Return () {
      window.history.go(-1);
    },
    getCompany () {
      let obj = { creater: this.item.creater };
      var objs = JSON.stringify(obj);
      let the = { index: 16, jsondata: objs }
      axios.post("/apis/AdministrationManage.asmx/GetData", the).then(({ data }) => {
        var list = eval('(' + data.d + ')');
        this.company = list;
      });
    },
    addlist () {
      if (this.Mark == 0) {
        if (this.item.Partners == "") {this.$message.error("请选择借车公司"); return; }
        if (this.item.Num == "") {this.$message.error("请填写数量"); return; }
        if (this.item.UseTime == "") {this.$message.error("使用时间非空"); return; }
        if (this.item.ReturnTime == "") {this.$message.error("归还时间非空"); return; }
        if (this.item.GoAddreess == "") {this.$message.error("去往地点分空"); return; }
        if (this.item.FromAddress == "") {this.$message.error("发车地点非空"); return; }
        if (this.item.Reasons == "") {this.$message.error("借车事由非空"); return; }
        var objs = JSON.stringify(this.item); let the = { index: 6, jsondata: objs };
       this. Mark = 1;
        axios.post("/apis/AdministrationManage.asmx/Add", the).then(({ data }) => {
          var list = JSON.parse(data.d);
          if (list.flag == true) {
            this.$message.success(list.tip);
            setTimeout(() => {
              window.history.go(-1);
            }, 500);          }
          else { this.$message.error(list.tip); }
        });
      }
    },
  }
}
</script>
<style lang="scss" scoped>
@import '@/assets/scss/base.scss';
.top-box {
  width: 100%;
  height: 60px;
  overflow: hidden;
  // border: 1px solid $red;
}
.left-box {
  width: 100px;
  height: 40px;
  float: left;
  margin-top: 10px;
  overflow: hidden;
  margin-left: 1%;
  // border: 1px solid red;
}
.color-box {
  width: 5px;
  height: 20px;
  float: left;
  margin-top: 10px;
  background-color: $Header_color;
}
.left-box p {
  float: left;
  margin-left: 5px;
  line-height: 40px;
}
.right-box {
  float: right;
  width: 90px;
  height: 40px;
  margin-right: 2%;
  border-radius: 8px;
  margin-top: 10px;
  background-color: $return-color;
  // border: 1px solid red;
}
.right-box:hover {
  background-color: #a4a6ad;
}
.right-box span {
  float: left;
  color: $white;
  font-size: $font-size-medium;
  line-height: 40px;
  //  border: 1px solid red;
}
.el-radio-group {
  margin-left: 10%;
}
.right-box img {
  width: 30px;
  height: 30px;
  margin-top: 5px;
  margin-left: 6px;
  float: left;
  // border: 1px solid red;
}
.content-box {
  width: 98%;
  height: 700px;
  margin: 0 auto;
  border-radius: 8px;
  background-color: $white;
  border: 1px solid $bordercolor;
}
.table-box {
  width: 85%;
  margin: 0 auto;
  overflow: hidden;
  margin-top: 80px;
  border-left: 1px solid $bordercolor;
  border-top: 1px solid $bordercolor;
  border-right: 1px solid $bordercolor;
}
.table-box li {
  width: 100%;
  height: 70px;
  overflow: hidden;
  border-bottom: 1px solid $bordercolor;
}
.table-box ul .large-box {
  display: flex;
  width: 100%;
  height: 200px;
  overflow: hidden;
  // border: 1px solid red;
}
.item5-box {
  width: 10%;
  height: 200px;
  float: left;
  line-height: 200px;
  text-align: center;
  color: $blackcolor;
  font-size: $font-size-medium;
  font-weight: bold;
  border-right: 1px solid $bordercolor;
}
.item6-box {
  flex: 1;
}
.item6-box textarea {
  width: 100%;
  height: 200px;
  border: none;
  outline: none;
  padding-top: 90px;
  font-size: 16px;
  text-align: center;
  //  padding-left:5%;
}
.item-box {
  width: 10%;
  height: 70px;
  float: left;
  line-height: 70px;
  text-align: center;
  color: $blackcolor;
  font-size: $font-size-medium;
  font-weight: bold;
  border-right: 1px solid $bordercolor;
}
.item1-box {
  width: 40%;
  height: 70px;
  float: left;
  line-height: 70px;
  // text-align: center;
  border-right: 1px solid $bordercolor;
}
.item1-box input {
  width: 90%;
  height: 70px;
  border: none;
  outline: none;
  margin-left: 10%;
  font-size: $font-size-medium;
  //  text-align: center;
}
.item2-box {
  width: 39%;
  height: 70px;
  line-height: 70px;
  // text-align: center
  float: left;
}
.item2-box input {
  width: 90%;
  height: 70px;
  border: none;
  outline: none;
  margin-left: 10%;
  font-size: $font-size-medium;
}
.block {
  margin-left: 10%;
}
.btn-box {
  width: 20%;
  height: 60px;
  margin: 0 auto;
  margin-top: 40px;
  padding-left: 100px;
  // border: 1px solid red;
}
</style>